package com.kuang.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName : MyMetaObjectHandler  //类名
 * @Description :   //描述
 * @Author : HTB  //作者
 * @Date: 2020-03-23 16:07  //时间
 */
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    //添加填充策略
    @Override
    public void insertFill(MetaObject metaObject) {
    log.info("start insert fill ....");
    this.setFieldValByName("createTime",new Date(),metaObject);
    this.setFieldValByName("updateTime",new Date(),metaObject);

    }

    //更新填充策略
    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("start update fill ....");
        this.setFieldValByName("operator", "Tom", metaObject);
        //this.setUpdateFieldValByName("operator", "Tom", metaObject);
    }
}
